//
//  MIniVideoPlayWindow.m
//  CoJellyCartoon
//
//  Created by dllo on 16/4/9.
//  Copyright © 2016年 CJG. All rights reserved.
//

#import "MIniVideoPlayWindow.h"

@implementation MIniVideoPlayWindow

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self creatPlayer];
        [self creatPlayView];
        [self creatPlayButton];
        
    }
    return self;
}

-(void)creatPlayer{
    self.miniPlayer = [VideoPlayer shareAVPlayer];
    self.miniPlayer.volume = 0.5f;
   
    AVPlayerLayer *playLayer = [AVPlayerLayer playerLayerWithPlayer:self.miniPlayer];
    playLayer.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 200);
    playLayer.videoGravity = AVLayerVideoGravityResize;
    
    [self.layer addSublayer:playLayer];
}
-(void)creatPlayView{
    self.PlayView = [[UIView alloc] initWithFrame:CGRectMake(0, self.bounds.size.height - (self.bounds.size.height / 4), self.bounds.size.width, self.bounds.size.height / 4)];
    self.PlayView.backgroundColor = [UIColor lightGrayColor];
    self.PlayView.alpha = 0.5;
    [self addSubview:self.PlayView];
}

-(void)creatPlayButton{
    self.PlayBtn = [UIButton buttonWithType:UIButtonTypeSystem];
    [self.PlayBtn setImage:[UIImage imageNamed:@"L3"] forState:UIControlStateNormal];
    self.PlayBtn.frame = CGRectMake(5, 0, 20, self.PlayView.bounds.size.height);
    [self.PlayView addSubview:self.PlayBtn];
}


@end
